package com.dayaokeji.rhythmschoolstudent.client.home.helper


import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.provider.Settings
import android.support.v4.app.Fragment
import android.text.Html
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.dayaokeji.rhythmschoolstudent.R

import com.dayaokeji.rhythmschoolstudent.client.common.base.ActivityTemplateMethod
import kotlinx.android.synthetic.main.fragment_helper_step_one.*


/**
 * @author feiwo
 *
 * course sign failed helper step 1
 *
 */
class HelperStepOneFragment : Fragment(), ActivityTemplateMethod {


    companion object {
        fun newInstance() = HelperStepOneFragment()
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                              savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.fragment_helper_step_one, container, false)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        init()
        setOnListener()
    }

    override fun setupView() {
        btnLeft.visibility = View.GONE
        btnRight.visibility = View.GONE
        btnCenter.visibility = View.VISIBLE

        btnCenter.setBackgroundDrawable(activity?.resources?.getDrawable(R.drawable.btn_common_bg_gray))
        btnCenter.setTextColor(Color.parseColor("#5A5A5A"))
    }

    override fun setupViewData() {
        val helperStr = "1.签到功能需要相关开关，请确认<font color='#6FB7FF'><b>【移动数据网络】</b></font>、<font color='#6FB7FF'><b>【位置信息】</b></font>、<font color='#6FB7FF'><b>【WIFI】</b></font>、<font color='#6FB7FF'><b>【GPS】</b></font>开关是否打开？<br/><br/>目前很多手机【位置信息】与【GPS】合并，以小米手机为例：";

        tvHelperTips.text = Html.fromHtml(helperStr)

        ivHelperImg.setImageResource(R.mipmap.img_course_sign_failed_step_1)

        btnCenter.text = "已打开"
    }

    private fun setOnListener() {
//        btnLeft.setOnClickListener {
//            activity?.let {
//                if (it is CourseSignFailedHelperActivity) {
//                    it.nextPage()
//                }
//            }
//        }
//
//        btnRight.setOnClickListener {
//            activity?.let {ac ->
//                val intent = Intent(Settings.ACTION_SETTINGS)
//                ac.startActivity(intent)
//            }
//        }

        btnCenter.setOnClickListener {
            activity?.let {
                if (it is CourseSignFailedHelperActivity) {
                    it.nextPage()
                }
            }
        }
    }
}
